//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.andromeda.androbench2;

import android.app.TabActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

public class main extends TabActivity implements OnTabChangeListener {
    static final int KBYTE = 1024;
    static final int MBYTE = 1048576;
    static TabHost mTabHost;
    BroadcastReceiver br_changeTab = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            int var3 = intent.getIntExtra("CHANGE_TARGET", 0);
            main.this.mSprefFlag = main.this.getSharedPreferences("Flags", 0);
            main.this.mSprefEditorFlag = main.this.mSprefFlag.edit();
            main.this.mSprefEditorFlag.putBoolean("MicroBench", intent.getBooleanExtra("MICRO", false));
            main.this.mSprefEditorFlag.putBoolean("SqliteBench", intent.getBooleanExtra("SQLITE", false));
            main.this.mSprefEditorFlag.commit();
            main.mTabHost.setCurrentTab(var3);
        }
    };
    Intent intent;
    Resources res;
    SharedPreferences mSprefData;
    SharedPreferences mSprefFlag;
    Editor mSprefEditorData;
    Editor mSprefEditorFlag;
    TabSpec mTabSpec;

    public main() {
    }

    public void onCreate(Bundle var1) {
        super.onCreate(var1);
        this.setContentView(R.layout.mainactivity);
        this.getWindow().addFlags(128);
        this.startActivity(new Intent(this, SplashActivity.class));
        this.mSprefData = this.getSharedPreferences("Settings", 0);
        this.mSprefEditorData = this.mSprefData.edit();
        this.mSprefEditorData.putInt("TargetDevice", 0);
        this.mSprefEditorData.putInt("IOType", 0);
        this.mSprefEditorData.putInt("OneFileSize", 65536);
        this.mSprefEditorData.putInt("TestRecs_RAND", 2048);
        this.mSprefEditorData.putInt("BufferSize_SEQ", 32768);
        this.mSprefEditorData.putInt("BufferSize_RND", 4);
        this.mSprefEditorData.putInt("Num_Thread", 8);
        this.mSprefEditorData.putInt("Num_Sqlite", 2048);
        this.mSprefEditorData.putInt("TransactionSize", 1);
        this.mSprefEditorData.putString("JournalMode", "WAL");
        this.mSprefEditorData.putInt("IndexUsage", 1);
        this.mSprefEditorData.putInt("DatabaseSize", 8);
        Point point = new Point();
        this.getWindowManager().getDefaultDisplay().getSize(point);
        point.y -= this.getTabHost().getTabWidget().getLayoutParams().height;
        this.mSprefEditorData.putInt("WindowWidth", point.x);
        this.mSprefEditorData.putInt("WindowHeight", point.y);
        this.mSprefEditorData.commit();
        this.mSprefFlag = this.getSharedPreferences("Flags", 0);
        this.mSprefEditorFlag = this.mSprefFlag.edit();
        this.mSprefEditorFlag.putBoolean("StartingBench", false);
        this.mSprefEditorFlag.commit();
        this.res = this.getResources();
        mTabHost = this.getTabHost();
        this.intent = (new Intent()).setClass(this, Startupbench.class);
        this.mTabSpec = mTabHost.newTabSpec("tab_1").setIndicator(new main.MyTabView(this, "")).setContent(this.intent);
        mTabHost.addTab(this.mTabSpec);
        this.intent = (new Intent()).setClass(this, Result.class);
        this.mTabSpec = mTabHost.newTabSpec("tab_2").setIndicator(new main.MyTabView(this, "")).setContent(this.intent);
        mTabHost.addTab(this.mTabSpec);
        this.intent = (new Intent()).setClass(this, History.class);
        this.mTabSpec = mTabHost.newTabSpec("tab_3").setIndicator(new main.MyTabView(this, "")).setContent(this.intent);
        mTabHost.addTab(this.mTabSpec);
        this.intent = (new Intent()).setClass(this, Setting.class);
        this.mTabSpec = mTabHost.newTabSpec("tab_4").setIndicator(new main.MyTabView(this, "")).setContent(this.intent);
        mTabHost.addTab(this.mTabSpec);
        mTabHost.setOnTabChangedListener(this);
        int var20 = this.getTabHost().getTabWidget().getLayoutParams().width;
        int var21 = (int) ((double) point.x / (double) var20 * (double) this.getTabHost().getTabWidget().getLayoutParams().height);
        this.getTabHost().getTabWidget().getLayoutParams().width = point.x;
        this.getTabHost().getTabWidget().getLayoutParams().height = var21;
    }

    public void onResume() {
        super.onResume();
        IntentFilter var1 = new IntentFilter("com.androbench.CHANGE_TAB");
        this.registerReceiver(this.br_changeTab, var1);
    }

    public void onStop() {
        super.onStop();
        this.unregisterReceiver(this.br_changeTab);
    }

    public void onTabChanged(String var1) {
        if (var1.equals("tab_1")) {
            mTabHost.getTabWidget().setBackgroundResource(R.drawable.tab_benchmarking);
        } else {
            if (var1.equals("tab_2")) {
                mTabHost.getTabWidget().setBackgroundResource(R.drawable.tab_result);
                return;
            }

            if (var1.equals("tab_3")) {
                mTabHost.getTabWidget().setBackgroundResource(R.drawable.tab_history);
                return;
            }

            if (var1.equals("tab_4")) {
                mTabHost.getTabWidget().setBackgroundResource(R.drawable.tab_setting);
                return;
            }
        }

    }

    private class MyTabView extends LinearLayout {
        public MyTabView(Context var2, String var3) {
            super(var2);
            TextView var4 = new TextView(var2);
            var4.setText("\n\n" + var3);
            var4.setTextColor(-1);
            var4.setGravity(1);
            var4.setTypeface(Typeface.createFromAsset(main.this.getApplicationContext().getAssets(), "fonts/PT_Sans-Web-Regular.ttf"));
            this.setOrientation(1);
            this.addView(var4);
        }
    }
}
